• Resolved hazratnoor

    (@hazratnoor)


    I am using the Advanced Ads plugin for a couple of months and is working fine. As soon I installed this powerful plugin, I find it the most perfect and powerful solution for all of my core requirements.

    Based on the fact that I have different users registered on my website i.e. Administrator, Advertisers, Subscribers, Customers, etc. Because I am using the Advanced Ads plugin for allowing Advertiser users to place their Ads on my website, so I need a bit of customization in the appearance of this plugin for Advertiser Users only.

    I do not want Advertiser users to see the Display Conditions, Visitor Conditions, Layout/Output sections and Stop/Start Wizard button functionality. Because when they create a new Ad, these sections including the Start/Stop Wizard button confuse the user.

    For this purpose, I need some way to configure the Start/Stop Wizard button such that when an Advertiser user clicks on the “Create New Ad” button, he always find the Wizard in start mode (not in stop mode). Because, when I configure the Start/Stop Wizard functionality like this, I will simply hide those target sections for Advertiser Users like the Display Conditions, Visitor Conditions, and Layout/Output sections so they won’t mess with them again. Currently, when advertiser clicks on the New Ad button and the Wizard on the next page appears either in Stop or Start mode. If he will change the Wizard appearance from Stop To Start and Vice Versa and then refresh the page (do not proceed with saving the ad) and clicks on the Create Ad button again, the Stop/Start Wizard functionality remains the same as he left that before refreshing the page.

    I can resolve the rest of the stuff if only I get some way to change the default appearance behavior of the button i.e. The Wizard functionality always appears to be in Start mode (not in the stopped form so users do not need to click on the button saying Start Wizard).

    For now, I have hidden a few Sub_Menu items of Advanced Ads Main Menu for Advertiser Users, However, Administrator still saw them on the Admin side like:
    -Advanced Ads
    -Groups & Rotation
    -Placement
    -Settings
    -Support

    I have used the following code for hiding these sub_menu items on the Admin side for Advertiser Users:

    add_action( 'admin_init', 'my_remove_menu_pages' );
    function my_remove_menu_pages() {
     
    global $user_ID;
     
    if ( current_user_can( 'advertiser' ) ) {
    		remove_submenu_page( 'advanced-ads', 'advanced-ads' );
    		remove_submenu_page( 'advanced-ads', 'advanced-ads-groups' );
    		remove_submenu_page( 'advanced-ads', 'advanced-ads-placements' );
    		remove_submenu_page( 'advanced-ads', 'advanced-ads-settings' );
    	}
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Thomas Maier

    (@webzunft)

    Hi hazratnoor,

    thanks for reaching out.

    I would suggest using some additional CSS and JavaScript to tinker with the Wizard. However, I am thinking about some larger changes to that feature and want to spare you to re-develop something in case my ideas are implemented.

    Would disabling the Wizard and instead hide some meta boxes (e.g., Display Conditions) per user role be an option for you?

    Thanks,
    Thomas

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    That’s exactly what I need. If applicable in-fact, there needs to be some way for allowing admin to hide/show sections/components based on user role.

    In my case, I was thinking about JavaScript and CSS as my only solution in-case I would not hear from you back. So I would like to confirm that is JavaScript code smart enough to bypass the plugin’s default feature (disable the wizard)? If yes, then how will I specify in my JS code that you (the Wizard) must stay hidden. I think JS may handle this using the wizard id?

    Plugin Author Thomas Maier

    (@webzunft)

    Hi nazratnoor,

    I am not able to provide the customizations myself, but am happy to point you to the appropriate files in the plugin:

    You can find the code that registers meta boxes in the add_meta_boxes() function in wp-content/plugins/advanced-ads/admin/includes/class-meta-box.php. Just unregister the ones you don’t need.

    You could close the wizard dynamically using

    <script>jQuery( document ).ready(function ($) { advads_wizard.close() });</script>

    You can find the code for that in wp-content/plugins/advanced-ads/admin/assets/js/wizard.js.

    Best regards,
    Thomas

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    The JS Code works for me.

    I simply added the following code to a custom .js file and enqueued this file in my functions.php.

    jQuery(document).ready(function(){
        if(!$('#advads-stop-wizard').hasClass('hidden')){
    		$('#advads-stop-wizard').trigger('click');
    	}
    });

    After adding the code, I refresh the page and then click on the “Create Ad” button. The JS code triggered the Stop Wizard button and this was what I was looking for. Later, I added targeted CSS code (for advertiser users only) and hide those sections including the Stop/Start Wizard button and hide them. Now, Advertiser users just create a new ad and cannot change anything else.

    Also, I would like to appreciate your contribution in creating such a great plugin.

    Plugin Author Thomas Maier

    (@webzunft)

    Hi hazratnoor,

    > Now, Advertiser users just create a new ad and cannot change anything else.

    Does it mean that you found the solution and all is well?

    Best regards,
    Thomas

    Thread Starter hazratnoor

    (@hazratnoor)

    Hi Thomas!

    Yes, based on using specific JavaScript & CSS files (which loads only if an Advertiser User is logged-in). These files (CSS & JS) are enqueued in my functions.php based on user role i.e. if Advertiser user is logged in, then load these files. The JS file simply contain the following lines of code:

    jQuery(document).ready(function(){
        if(!$('#advads-stop-wizard').hasClass('hidden')){
    		$('#advads-stop-wizard').trigger('click');
    	}
    });

    As soon as a user will try to create a new ad, this code will not allow the Wizard to start. So the user will simply put the title, add description/image and hit the publish button on the right side.

    Also, I have hide sections which were not required for advertiser user i.e. display conditions etc…

    Plugin Author Thomas Maier

    (@webzunft)

    Great, thanks for sharing your solution!

    Thomas

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to hide/remove some sections of advanced ads plugin for advertiser user?’ is closed to new replies.