Support

Account

Forum Replies Created

  • Elliot,

    I’m pretty new at PHP, but you were able to point me in the right direction. I did need to define the variables in the widget, and now it works.

    <?php global $author_id ?>
    <?php $author_id = get_current_user_id(); ?> 

    Really appreciate your help and your time with this!

  • We have custom fields set up this way:

    screenshot text fields

    A PHP programmer initially set up the sidebar HTML/PHP code in the template pages (home.php, page.php, etc). In there, the custom fields work, the hyperlinks are generated correctly. The custom text fills in to match the logged in user’s custom fields, creating custom links.

    I’m trying to move back to a more standard usage of the WordPress sidebar, where some widgets can be changed in the sidebar, as normal.

    For the widget where the custom text will populate, I set up a Custom Text Widget, with a plugin to allow it to accept PHP/HTML. Then, I pasted the code in. The variables aren’t processing when used in this widget. They are generated as $my_goals, rather than the value for $my_goals filling in, for example.

    This is the code in the widget:

    <ul class="menu" id="menu-my-stuff">
    
    <?php $my_goals =  get_field('_my_goals', 'user_'. $author_id ); $my_goals = $my_goals ? $my_goals : '#';?>
    <li class="menu-item ">
    	<?php echo "<a target=blank href=$my_goals>my Goals</a>" ?>
    </li>
    
    <?php $my_analytics =  get_field('_my_analytics', 'user_'. $author_id ); $my_analytics = $my_analytics ? $my_analytics : '#';?>
    <li class="menu-item ">
    	<?php echo "<a target=blank href=$my_analytics>my Analytics</a>" ?>
    </li>
    
    <li class="menu-item"><a href="http://wiki.wikigood.com/sugar" target="_blank">my Top Prospects</a></li>
    
    <?php $my_ad_scheduler =  get_field('_my_ad_scheduler', 'user_'. $author_id ); $my_ad_scheduler = $my_ad_scheduler ? $my_ad_scheduler : '#';?>
    <li class="menu-item ">
    	<?php echo "<a target=blank href=$my_ad_scheduler>my Ad Scheduler</a>" ?>
    </li>
    
    <?php $my_commission_report =  get_field('_my_commission_report', 'user_'. $author_id ); $my_commission_report = $my_commission_report ? $my_commission_report : '#';?>
    <li class="menu-item ">
    	<a target=blank href="[acf field="{$my_commission_report}"]">my Commission Report </a>
    	<?php echo "<a target=blank href=$my_commission_report>my Commission Report</a>" ?>
    	<?php echo( '<a href=$my_commission_report>Click Me</a>' ); ?>
    </li>
    
    </ul>
    <p><?php the_field('$my_commission_report'); ?></p>
Viewing 2 posts - 1 through 2 (of 2 total)