• Resolved leaklords

    (@kwark)


    Hi,

    Thank you for your great plugins.

    I try to add a function since some days on special meta and before the line 221 in wpfu-add-post.php

    i desire to create a function to test some new meta in new custom field created with wpfu and to verify if a shortened link exist on my installation of yourls but i don’t understand what happens and how to hack lightly your code without i make a bug

    $shortend = trim( strip_tags( $_POST[$fiels['cf_shortend']] ) );
        $longurl = trim( strip_tags( $_POST[$fiels['cf_longurl']] ) );
    
    	if( (empty( $shortend )) ) {
            $errors[] = "No ending link selected";
        }
    	if( (preg_match('#^\/#', $shortend )) ) {
            $errors[] = "No trailing slash please";
        }
    	if( (preg_match('#^http:\/\/#', $shortend )) ) {
            $errors[] = "Just the end please after ".$dom."";
        }
    	if( (empty( $longurl )) ) {
            $errors[] = "No long url selected to make shortened";
        }
    	else{
        //var_dump( $_POST ); die();
    
    		$dom = 'domain.tld';
    		$url = ''.$dom.'/'.$shortend.'';
    		$format = 'json';
    		$api_url = ''.$domain.'/yourls-api.php';
    		require_once(dirname(__FILE__).'/jssec.php');
    
    		// Init the CURL session
    		$ch = curl_init();
    		curl_setopt($ch, CURLOPT_URL, $api_url);
    		curl_setopt($ch, CURLOPT_HEADER, 0);            // No header in the result
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return, do not echo result
    		curl_setopt($ch, CURLOPT_POST, 1);              // This is a POST request
    		curl_setopt($ch, CURLOPT_POSTFIELDS, array(     // Data to POST
    				'timestamp' => $timestamp,
    				'signature' => $signature,
    				'url'  		=> $longurl,
    				'keyword'	=> $short,
    				'format'    => $format,
    				'action'    => 'shorturl'
    			));
    
    		// Fetch and return content
    		$apinegoce = curl_exec($ch);
    		curl_close($ch);
    
    			if (!$apinegoce)
    			{
    				$errors[] = "Shortener services is on maintenance actually."; //if in Maintenance
    			}
    			else
    			{
    				// Do something with the result.
    				$recho = json_decode($apinegoce, true);
    				// Process data
    				$ggstatus = $recho['statusCode'];
    
    				if($ggstatus = '200'){}
    				else{
    						$errors[] = "A shortener link exist with this shortened. Please choose another one.";
    						$errors[] = ''.$apinegoce.'';
    					}
    			}
    		}
        } //is_array

    https://www.ads-software.com/extend/plugins/wp-user-frontend/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tareq Hasan

    (@tareq1988)

    should work ??

    Thread Starter leaklords

    (@kwark)

    Ah ok thank you for your kick response. I had some doubts about my piece of code. I look at the other side (yourls) to test the problem of this small hack

    Plugin Author Tareq Hasan

    (@tareq1988)

    I forgot to say, you could use the plugin API that this plugin offers. There is a filter for adding custom validation rule. You could use that in this case and could avoid editing the plugin directly.

    $errors = apply_filters( 'wpuf_add_post_validation', $errors ); in line 228 wpuf-add-post.php

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: WP User Frontend] i try to add some errors on meta in add-post.php’ is closed to new replies.