Skip to:
Content
Pages
Categories
Search
Top
Bottom

Buddy Press Private Message Delete Permission to Only Admin


  • Anonymous User 16484011
    Inactive

    @anonymized-16484011

    Hi !

    Prashant,

    I create this new topic because I can’t show previous topic last answer.

    So, Please here you paste your last answer from our previous topic please..

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)

  • Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    Please let me know if you are logged in as an administrator or not if yes then certainly the button will be visible to you but if not then you will not be able to see the button after wrapping the code.

    Your code seems fine to me and it should work for sure. Also please make sure that there are no ajax requests going on that creates the HTML there.

    Let’s debug it more. Please remember we are wrapping code for currently logged in user, not the user from which profile you are creating notifications.

    Thanks


    Prashant Singh
    Participant

    @prashantvatsh

    The last option we can try is CSS. I can give you a code that will hide that button for all the members except admins.


    Anonymous User 16484011
    Inactive

    @anonymized-16484011

    Hi !

    Prashant,

    First of all thank you very much for your reply here.

    Your first stanza’s answer is I always check twice with both the role’s admin and patient. But after wrapping the code both user’s after message creating page’s Delete button disappear.

    Your second stanza’s second line I can’t understand. What is ajax ? And how can I see or know that any ajax requests going on that creates the HTML there.

    Your third stanza’s last line confuse me. Please explain “not the user from which profile you are creating notifications.”

    Also I eagerly waiting for your css. Also tell me where exact can I paste that css.

    Thanks N Regards


    Prashant Singh
    Participant

    @prashantvatsh

    Please try this code:

    add_action('wp_footer','ps_remove_delete_button');
    function ps_remove_delete_button(){
    	if(!current_user_can('manage_options')){
    		?>
    		<script type="text/javascript">
    		jQuery(document).ready(function(){
    			jQuery('.notifications .delete').hide();
    			jQuery('.notifications .confirm').each(function() {
    			    if (jQuery(this).text() == 'Delete')
    			        jQuery(this).hide();
    			});
    		});
    		</script>
    		<?php
    	}
    }

    Please check if body tag has class ‘notifications’.

    Thanks


    Anonymous User 16484011
    Inactive

    @anonymized-16484011

    Hi !

    Prashant,

    It’s not work. I paste into snippet and check run this code everywhere.

    Can it’s possible that I’ll give you a link of plugin and can you check so, you got better idea.

    Plugin link : removed

    Regards


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    I have tried the same code

    <?php if(current_user_can('manage_options')){?>
    							<a class="delete" href="<?php bp_message_thread_delete_link( bp_displayed_user_id() ); ?>"><span class="dashicons dashicons-trash"></span></a>
    
    							<?php
    							}

    and

    <?php if(current_user_can('manage_options')){?>
    				
    				<a class="button confirm" href="<?php bp_the_thread_delete_link(); ?>"><i class="fas fa-trash-alt"></i><?php _e( 'Delete', 'youzer' ); ?></a>
    			<?php }?>

    Both are working super fine. If I am logged in as an admin user then only I have the capability otherwise not.

    Thanks


    shanebp
    Moderator

    @shanebp

    @harihealthcare

    You purchased a plugin and then posted a link to it here?
    What were you thinking?
    The creator of that plugin worked hard and now is trying to sell that plugin.
    What made you think it was okay to give it away for free?
    Did you ask permission of the plugin creator?
    The link has been removed from your post above.


    @prashantvatsh

    If you want to provide free support for premium plugins – please do it elsewhere.

    This thread is closed.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Buddy Press Private Message Delete Permission to Only Admin’ is closed to new replies.
Skip to toolbar