Forum Replies Created

Viewing 15 replies - 1 through 15 (of 23 total)
  • Thread Starter rocketmediauk

    (@rocketmediauk)

    Hi Paul, I edited my post to remove the bit I missed as I read the notes in the plugin and disabled overriding WP metadata and it worked.

    I am attempting to adjust the plugin so that it only shows the branded resource it available and the standard one it not which I think I have achieved with

    				if ( !empty( $branch_resources_html ) ) {
    				  printf(
    					  '<div>%s</div>',
    					  $branch_resources_html
    				  );
    				}else if( empty( $branch_resources_html ) ) {
    				  printf(
    					  '<div>%s</div>',
    					  $main_resource_html
    				  );
    				}
    Thread Starter rocketmediauk

    (@rocketmediauk)

    Thanks Paul, appreciated you would take the time to investigate this with such depth.

    I will have a look through the code and have a test. TY

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Hi Paul,

    Yes each user will have a company branch appended to the file name, which I can already make use of by using $userbranch from my code. So it would be $var = $linktitle.’ ‘.$userbranch (I would need to loop through company branches as a user may have more than one but I don’t need to address this yet) assuming I can get $linktitle.

    The main reason I chose to do the block and template is so that the admin user can easily add new resources to a page, I did start with custom coding this but it came back to me everytime they wanted to change something so I just thought the block was a simple way for them to achieve it.

    Thread Starter rocketmediauk

    (@rocketmediauk)

    <?php
    global $post;
    $post_slug = $post->post_name;
    
    $userid = get_current_user_id();
    $user_pod = pods( 'user', $userid  );
    
    $userbranch = $user_pod->field( 'user_company_branch' );
    
    //GET USER ID AND BRANCH 
    $user_pod = pods( 'user', $userid  );
    $userbranch = $user_pod->field( 'user_company_branch' );
    
    //AS THERE CAN BE MORE THAN ONE BRANCH CYCLE THROUGH AND SAVE TO AN ARRAY
    $key = 0;
    $branch_array = array(); //SET ARRAY
    if( $userbranch != NULL){
    	foreach ( $userbranch as $pod_detail ) { //LOOP THROUGH EACH OF THE TEAMS COACH ID
    		$linked_branch = pods('company_branch', $pod_detail['ID']);
    		$linked_companybranch = $linked_branch->display('branch_name');
    		$branch_array[$key] = $linked_companybranch;
    		$key++;
    	} //END foreach ( $userbranch as $pod_detail)
    }
    
    $post_id = get_the_ID();
    
    $linktitle = '{@resource_link_protected}'; 
    $linkid = '{@resource_link_protected.ID}';
    
    $branchdownload = '{@resource_link_protected}';
    	
    $wpdmargs = array(
    	  'post_type' => 'wpdmpro', 
    	  'posts_per_page' => -1
    );
    $wpdm_loop = new WP_Query( $wpdmargs ); // WP LOOP ARG AS ABOVE
    while ( $wpdm_loop->have_posts() ) : $wpdm_loop->the_post();
    	if( get_the_title() == $linktitle ){
    	  //THIS BIT WILL BE THE NEW DOWNLOAD WHICH I HAVEN'T FIGURED HOW TO GET YET.
    	}else{
    	  echo '[wpdm_package id="{@resource_link_protected.ID}" template="link-template-button"]';
    	}
    endwhile;
    wp_reset_query();
    ?>
    Thread Starter rocketmediauk

    (@rocketmediauk)

    Hi Paul,

    Sorry, let me try and explain and post my code so far.

    The site is to be used as a file resource, where a client can login and download a guide, an example title would be ‘Actions for Coaches Guide’. I can display the title and link fine.

    Why I need to start using loops etc. Some clients may be part of a company that have a specific file that they need to download, now rather then create a series of repeatable fields to add the different download for each company which would be very long winded I would add the download with the same title followed by the company name, for example ‘Actions for Coaches Guide ABC Bristol’. So my ideal was to set the variable as the title and append the company name to the end and then search through all downloads and display the company version if it exists.

    I have a POD called resource_link which has a relationship field called resource_link_protected which links to a download file with WP Download Manager

    I have extended the user roles with PODs so a user can be assigned (using a relationship in the user POD called user_company_branch) what I am calling a Branch which is a new POD called company_branch which just has the field branch_name.

    I am using the single item block where I select the resource_link_protected I want to show.

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Jeez all this to just set the title as a variable!

    Sorry if I am stupid but putting {@resource_link_protected.ID,run_a_loop} in my template shows an error unexpected token “,”

    And I still get errors ‘Call to undefined function do_magic_tags()’ when using do_magic_tags()

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Hi Paul,

    Still no luck, get_the_ID(); gets the ID of the page. I am using this inside a POD template which I select when using the PODs single Item block

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Ok so I am still having issues using in some PHP such as the If statement I put earlier. This is what I put:

    $podtitle =do_magic_tags('{@resource_link_protected}');
    while ( $wpdm_loop->have_posts() ) : $wpdm_loop->the_post();	
       if( get_the_title() == $podtitle){		
          echo 'IT WORKS';	
       }
    endwhile;

    I wonder if the problem exists in the encoding of the magic tages as when I var_dump $podtitle the string displays as it should but has a length of 51 while as the_title has a length of 37 even though they have the same string, so maybe some hidden characters are there?

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Ohh I put the function in functions.php and getting some return. I will test this

    function do_magic_tags( $code ){
    return $code;
    }
    Thread Starter rocketmediauk

    (@rocketmediauk)

    I get an error:
    Uncaught Error: Call to undefined function do_magic_tags()

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Hi Paul,

    Can you give me an example? There isn’t a lot of info on that page

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Thanks that works for the shortcode but I still need to save it as a variable which doesn’t seem to work

    This is what I have:

    In Function:

    function do_getid( $id ){
       return $id;
    }

    In File

    $test = '{@resource_link_protected, do_getid}';
    print_r($test); 
    //This shows the correct title which is Actions for Coaches Guide
    
    while ( $wpdm_loop->have_posts() ) :  $wpdm_loop->the_post();
       print_r(get_the_title());  
       //This show the titles in my loop, one of which is Actions for Coaches Guide
          if( get_the_title() == $test ){
             echo 'IT WORKS!'; //This doesn't display   
          }
    }

    So setting the variable to a magic tag for some reason doesn’t work because if I was to manually change $test to $test = ‘Actions for Coaches Guide’; it does work

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Hi Paul,

    How do I get the ID when I am in a template for ‘Single Pods Item’ block? The info on your page says $books = pods( ‘books’, 123 ); but I can’t get the ID of the selected POD to use instead of 123 as I can’t set magic tags as variables.

    With get_post_meta, that will give me the meta for the page I am displaying the blocks on, but again I need the POD ID to be able to get useful information, which I am unable to do.

    Or am I missing something?

    I assume from your answer there is noway to set a magic tag as a variable? Such as $test = {@resource_link_protected.ID}. Because these doesn’t work for PHP If statements for example.

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Is this the best way to get support or is this plugin just not very well supported?

    Thread Starter rocketmediauk

    (@rocketmediauk)

    Anyone?

Viewing 15 replies - 1 through 15 (of 23 total)